package ua.epam.muzalevskiy.traction.dao;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.ResourceBundle;

/**
 * This is realization of <code> ConnectionFactory </code> without
 * Connection Pool.
 *
 * @author Muzalevskiy Vitaliy
 */
public class ConnectionFactoryJdbc implements ConnectionFactory{
    
    /** This value need to connect to DataBase.*/
    private static final String JDBC_URL;  
    /** Login that we need to connect to concrete DataBase Server.*/
    private static final String LOGIN;
    /** Password that we need to connect to concrete DataBase Server.*/
    private static final String PASSWORD;

static {
    	final ResourceBundle config = ResourceBundle
                .getBundle("ua.epam.muzalevskiy.traction.dao.dbconnection");
    	JDBC_URL = config.getString("db.url");
    	LOGIN = config.getString("db.login");
    	PASSWORD = config.getString("db.password");
    }

    @Override
    public Connection newConnection() throws SQLException {
        return DriverManager.getConnection(JDBC_URL, LOGIN, PASSWORD);
    }

    @Override
    public void close() throws SQLException {
        throw new UnsupportedOperationException("Not supported yet.");
    }
    
}
